#!/bin/sh

NAME=hotkeygen
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME.pid
DAEMON_ARGS=--permanent

# Sanity checks
test -x $DAEMON || exit 0

start() {
        printf "Starting $NAME: "
        start-stop-daemon --start --quiet -m --pidfile $PIDFILE --exec $DAEMON --background -- $DAEMON_ARGS > /var/log/hotkeygen.log 2>&1 \
                && echo "OK" || echo "FAIL"
}

stop() {
        printf "Stopping $NAME: "
        start-stop-daemon --stop --quiet --pidfile $PIDFILE \
                && echo "OK" || echo "FAIL"
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac
